package no.la58.scribbles.client.uicomponents;

import java.util.Date;

import no.la58.scribbles.shared.Scribble;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class ScribbleView extends Composite {

    private static ScribbleViewUiBinder uiBinder = GWT.create(ScribbleViewUiBinder.class);

    interface ScribbleViewUiBinder extends UiBinder<Widget, ScribbleView> {
    }

    @UiField
    SpanElement scribbleText;

    @UiField
    SpanElement timestampText;

    @UiField
    SpanElement userInfo;

    public ScribbleView(Scribble scribble) {
	initWidget(uiBinder.createAndBindUi(this));
	userInfo.setInnerText(scribble.getUsermail());
	scribbleText.setInnerText(scribble.getMessage());
	Date date = new Date(scribble.getTimeStamp());
	timestampText.setInnerText(DateTimeFormat.getMediumDateTimeFormat().format(date));
    }

}
